<?php
$this->title = "发布图片";
?>

<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use common\models\Category;
use kartik\widgets\Select2;
use common\WuMing;
use yii\widgets\Pjax;

/* @var $this yii\web\View */
/* @var $model frontend\models\Post */
/* @var $form yii\widgets\ActiveForm */
?>
<?php Pjax::begin() ?>
<div class="main  pd20 mb20  post-create">
    <div role="tabpanel">

        <!-- Nav tabs -->
        <ul class="nav nav-tabs" role="tablist">
            <li role="presentation"><a href="<?= Yii::$app->urlManager->createUrl("post/article") ?>">帖子</a></li>
            <li role="presentation" class="active"><a href="<?= Yii::$app->urlManager->createUrl("post/pic") ?>">图片</a>
            </li>
            <li role="presentation"><a href="<?= Yii::$app->urlManager->createUrl("post/url") ?>">链接</a></li>
        </ul>

        <!-- Tab panes -->
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="home">
                <div class="post-form">

                    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>

                    <?= $form->field($model, 'title')->textInput(['maxlength' => 100, 'placeholder' => '请输入图片标题'])->label("") ?>

<!--                    --><?//= $form->field($model, 'cid2')->widget(Select2::className(), [
//                        'data' => ArrayHelper::map(WuMing::getUserCategory(Yii::$app->user->id, false), 'id', 'name'),
//                        'language' => 'en',
//                        'options' => ['placeholder' => '请选择需要发布到的揭示板'],
//                        'pluginOptions' => [
//                            'allowClear' => true
//                        ]
//                    ])->label(false) ?>

                    <?= $form->field($model, 'thumb')->fileInput()->label("上传图片") ?>

                    <?= $form->field($model, 'content')->textarea(['rows' => 6])->label("简要描述(选填)") ?>
                    <div class="form-group">
                        <label for="">揭示板(必选)</label>
                        <div class="tagslist">
                            <?php $cates = WuMing::getUserCategory(Yii::$app->user->id, false) ?>
                            <?php foreach($cates as $v):?>
                                <span class="list-tag" data-id="<?=$v['id']?>"><?=$v['name']?></span>
                            <?php endforeach;?>
                        </div>
                    </div>
                    <?= $form->field($model, 'cid2')->hiddenInput(['class'=>'cate-cid'])->label(false) ?>

                    <div class="clearfix"></div>
                    <div class="form-group">
                        <?= Html::submitButton('发布帖子', ['class' => 'btn btn-primary']) ?>
                    </div>

                    <?php ActiveForm::end(); ?>

                </div>
            </div>

        </div>

    </div>
</div>
<?php Pjax::end()?>